package com.jishuo.nontax.api.socket;

import com.jishuo.nontax.api.socket.handle.*;

import java.util.HashMap;
import java.util.Map;

/**
 * 接口工厂类，定义接口名称、业务类直接的关系
 *
 * @author jhb
 * @date 2023-1-29
 */
public class ApiFactory {
    // 业务类定义
    static Map<String, ApiHandle> apiMap = new HashMap<>();

    static {
        apiMap.put("EticketNum", new EticketNumApi());
        apiMap.put("PaySpecial", new PaySpecialApi());
        apiMap.put("IllegalactivityScaleinfo", new PayScaleBillApi());
        apiMap.put("PayFisc", new PayFiscApi());
        apiMap.put("PayDivide", new PayDivideApi());
        apiMap.put("Illegalactivityinfo", new IllegalactivityInfoApi());
        apiMap.put("BackBill", new BackBillApi());
        apiMap.put("ChargeBill", new ChargeBillApi());
        apiMap.put("WaitaffirmPayInfo", new WaitaffirmPayInfoApi());
        apiMap.put("Waitaffirm", new WaitaffirmApi());
        apiMap.put("PunishLatefee", new PunishLatefeeApi());
        apiMap.put("BaseData", new BaseDataApi());
        apiMap.put("DailiBank", new DailiBankApi());
        apiMap.put("Unit", new UnitApi());
        apiMap.put("Item", new ItemApi());
        apiMap.put("Student", new StudentApi());
        apiMap.put("Deduct", new DeductApi());
        apiMap.put("BankBalance", new BankBalanceApi());
        apiMap.put("BankCheckBill", new BankCheckBillApi());
        apiMap.put("EpayFisc", new EpayFiscApi());
        apiMap.put("BankPos", new BankPosApi());
    }

    // 接口名称，返回业务类名称
    enum Api {
        getEticketNum("EticketNum"),
        setEticketNumDeposit("EticketNum"),
        setEticketNumDepositOnLine("EticketNum"),
        getEticketNumOnLine("EticketNum"),
        getPaySpecial("PaySpecial"),
        setSpecialPayInfo("PaySpecial"),
        getIllegalactivityScale("IllegalactivityScaleinfo"),
        sendIllegalactivityScaleBankaffirm("IllegalactivityScaleinfo"),
        setIllegalactivityScaleBankaffirm("IllegalactivityScaleinfo"),
        getPayFisc("PayFisc"),
        setFiscPayInfo("PayFisc"),
        getPayDivide("PayDivide"),
        setDividePayInfo("PayDivide"),
        getIllegalactivityInfo("Illegalactivityinfo"),
        setPayInfo("Illegalactivityinfo"),
        setIllegalactivityCrossPayInfo("Illegalactivityinfo"),
        setPunishBillnum("Illegalactivityinfo"),
        getIllegalactivityInfoOnLine("Illegalactivityinfo"),
        getIllegalactivityInfoDepositOnLine("Illegalactivityinfo"),
        setWaitaffirm("Waitaffirm"),
        sendWaitaffirm("Waitaffirm"),
        cleanWaitaffirm("Waitaffirm"),
        regetWaitaffirm("Waitaffirm"),
        resetWaitaffirmInfo("Waitaffirm"),
        setWaitaffirmPayInfo("WaitaffirmPayInfo"),
        sendWaitAffirmPayInfo("WaitaffirmPayInfo"),
        getChargeBill("ChargeBill"),
        setChargeBillDeposit("ChargeBill"),
        setChargeBillIsActive("ChargeBill"),
        setChargeBillManual("ChargeBill"),
        getBackbill("BackBill"),
        setBackBillDeposit("BackBill"),
        // ------------------------------------基础数据-----
        findPayway("BaseData"),
        findPayertype("BaseData"),
        findKeyword("BaseData"),
        findCanton("BaseData"),
        findBank("BaseData"),
        sendBankStation("BaseData"),
        confirmBank("BaseData"),
        selDailiBank("DailiBank"),
        findUnit("Unit"),
        selUnit("Unit"),
        findUnitByUnitCode("Unit"),
        selBaseUnit("Unit"),
        selNewItem("Item"),
        getLatefee("PunishLatefee"),
        setPunishInfo("PunishLatefee"),
        getStudent("Student"),
        getStudentOnLine("Student"),
        setStudentDepositOnLine("Student"),
        setStudentPayInfo("Student"),
        findPayInfoOnLine("Student"),
        listPayInfoOnLine("Student"),
        setDeduct("Deduct"),
        setNewDeduct("Deduct"),
        sendDeduct("Deduct"),
        setBankBalance("BankBalance"),
        sendBankBalance("BankBalance"),
        sendBankCheckBill("BankCheckBill"),
        cleanBankCheck("BankCheckBill"),
        setBankCheckBill("BankCheckBill"),
        setBankPos("BankPos"),
        sendBankPos("BankPos"),
        setNewBankPos("BankPos"),
        sendNewBankPos("BankPos"),
        setSumPos("BankPos"),
        setPayFiscBatch("EpayFisc"),
        setPayFiscCheck("EpayFisc"),
        setPayFiscBack("EpayFisc"),
        setBankPayment("EpayFisc"),
        setPayFiscUnited("EpayFisc"),
        selUnitVsItem("Item"),
        findUnitVsItem("Item");


        private String apiCls;

        private Api(String apiCls) {
            this.apiCls = apiCls;
        }

        public String getApiCls() {
            return apiCls;
        }
    }

    /**
     * 获得接口业务类实例
     *
     * @param head 接口名称
     * @return
     * @throws Exception 接口不存在
     */
    public static ApiHandle getApi(String head) throws Exception {
        return apiMap.get(Api.valueOf(head).getApiCls());
    }
}
